package com.h3c.tj_nsh.Utils;


import android.content.Context;

import java.io.IOException;

import retrofit.GsonConverterFactory;
import retrofit.Retrofit;


/**
 * Time: 2016/5/13.
 * Author:Chen  .
 */
public class RetrofitUtils {
    private static Retrofit singleton;

    public static <T> T createApi(Context context, Class<T> clazz) throws IOException, ClassNotFoundException {
        if (singleton == null) {
            synchronized (RetrofitUtils.class) {
                if (singleton == null) {
                    Retrofit builder = new Retrofit.Builder()
                            .addConverterFactory(GsonConverterFactory.create(GsonUtils.newInstance()))
                            .baseUrl("http://192.168.127.211:8080/")
                         //   .baseUrl("http://gank.io/api/")
                            .client(OkHttpUtils.getInstance(context))
                            .build();
                    singleton = builder;
                }
            }
        }
        return singleton.create(clazz);
    }
}
